package com.xwdeshj.controller;

import com.alibaba.fastjson.JSONObject;
import com.xwdeshj.service.XwFarmDiscussinfoService;
import com.xwdeshj.utils.IMoocExceptionHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by BKWJA on 2019/1/6.
 * 农家乐——农家评论信息 控制类
 */
@Slf4j
@CrossOrigin(allowCredentials = "true")
@RequestMapping("farmdiscuss")
@Controller
public class XwFarmDiscussinfoController extends IMoocExceptionHandler {

    @Autowired
    private XwFarmDiscussinfoService xwFarmDiscussinfoService;

    /**
     * 获取农家乐店铺 评论信息
     * @param pageindex 当前页码
     * @param pagesize 每页显示多少
     * @param starttime 开始时间
     * @param endtime 结束时间
     * @param sortfild 排序字段
     * @param sortway 排序方式
     * @param searchval 搜索值
     * @param searchkey 搜索字段
     * @param farm_encryptId 店铺加密id
     * @param user_encryptId 用户加密id
     * @return
     */
    @RequestMapping("/getfarmdiscusslist")
    @ResponseBody
    public JSONObject getfarmdiscusslist(@RequestParam(value = "pageindex",defaultValue = "1")Integer pageindex,
                                      @RequestParam(value = "pagesize",defaultValue = "10") Integer pagesize,
                                      @RequestParam(value = "starttime",defaultValue = "") String starttime,
                                      @RequestParam(value = "endtime",defaultValue = "") String endtime,
                                      @RequestParam(value = "sortfild",defaultValue = "farm_discus_createtime")
                                              String sortfild,
                                      @RequestParam(value = "sortway",defaultValue = "desc")String sortway,
                                      @RequestParam(value = "searchval",defaultValue = "") String searchval,
                                      @RequestParam(value = "searchkey",defaultValue = "") String searchkey,
                                      String farm_encryptId,String user_encryptId, HttpServletRequest request){
        return xwFarmDiscussinfoService.getfarmdiscusslist(pageindex,pagesize,starttime,endtime,sortfild,sortway,
                searchval,searchkey,farm_encryptId,user_encryptId,request);
    }


    /**
     * 农家乐——删除评论信息
     * @param discus_id 评论id
     * @param request
     * @return
     */
    @RequestMapping("/deldiscussfarm")
    @ResponseBody
    public JSONObject deldiscussfarm(Integer discus_id,HttpServletRequest request){
        return  xwFarmDiscussinfoService.deldiscussfarm(discus_id,request);
    }


}
